/*
 * File:    vision_test.h
 * Purpose: Contains constants used in vision_test.c
 */

/*
 Copyright 2009 James Youngquist, Colin Scott.

 This file is part of ElectroGladiator.  ElectroGladiator is free
 software: you can redistribute it and/or modify it under the terms
 of the GNU General Public License as published by  the Free
 Software Foundation, either version 3 of the License, or (at your
 option) any later version.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _VISION_TEST
#define _VISION_TEST 1

#include "eg_vision.h"
#include "eg_geom.h"

#define XRES 600
#define YRES 600
#define DEPTH 32
// colors are 0xRRGGBBAA and 0xFF for alpha means opaque
#define WALL_COLOR 0x400000FF
#define POINT_COLOR 0xFF3030FF
#define PLAYER_COLOR 0xFFFFFFFF
#define ROCK_COLOR 0xFF0000FF

/* Initialize the map */
void init_map ();

/* Returns x coordinate scaled to screen dims */
int p2x (const Point *p);

/* Returns y coordinate scaled to screen dims */
int p2y (const Point *p);

/* Converts screen y to map y */
double s2m_x (int x);

/* Converts map y to screen y */
double s2m_y (int y);

/* draw a point on the screen */
void draw_p (SDL_Surface *surf, const Point *p);

/* draw a line to the screen */
void draw_l (SDL_Surface *surf, const Line *l, int color);

/* draw a trigon to the screen */
void draw_t (SDL_Surface *surf, const Trigon *t);

/* draw a player on the screen */
void draw_pl (SDL_Surface *surf, Player *p);

/* draw a rock on the screen */
void draw_r (SDL_Surface *surf, Rock *r);

/* draws all elements in a map */
void draw_map (SDL_Surface *surf, Map *m);

/* updates game state */
void game_tick ();

/**
 * Brings all player data up to date.
 * @param p The player to update.
 */
void update_player(Player *p);

/**
 * Creates a new rock at Player's location with same bearing as player as though
 * the player had just thrown this rock.
 * @param owner Player that owns this rock
 * @return The newly thrown rock
 */
Rock* throw_new_rock(Player *owner);

/* moves all rocks */
void move_rocks (Map *m);


/*
 * Checks for wall collisions (player collisions too?)
 * for the given rock. Returns the point of collision
 * if one was found, or NULL if no collision occurred.
 */
Point* r_collision (Line *path, Map *m); 

/*
 * Returns a line with endpoints at the rock's
 * current position, and at the full distance R_SPEED 
 * away. This is used for rock/player collision detection.
 */
Line* rock_path(const Rock *r);

#endif
